<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:include page="/WEB-INF/views/layouts/header.jsp" />
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
// 网站地址
String netPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
%>
<style>
.yhgltable ul li span.current {
	font-weight: bold
}

.chooseColumn {
	width: 196px;
	height: 30px;
	line-height: 30px;
	color: #666;
	border: 1px solid #BBB;
}

.chooseColumn option {
	height: 30px;
}

.next,.prev {
	filter: Alpha(opacity =50);
	-moz-opacity: .1;
	opacity: 0.5;
}
</style>
<script type="text/javascript">

	// 搜索
	var searchText = "";
	function clickSearch(){
		getSearchText();
		searchText = searchText?encodeURIComponent(searchText):"";
		$.ajaxSetup ({ cache: false });
		$(".userContent").load("<%=basePath%>column/searchColumn?searchText="+searchText);
	};
	
	function blurSearch(){
		getSearchText();
		clickSearch();
	}

	function getSearchText(){
		searchText = $("[name=searchText]").val()?$("[name=searchText]").val():"";
	}
	
 	function toInsert(){

		var url = "<%=basePath%>column/add";
		var HTML = '<div class="Popup">';
		HTML += '<div class="Popupheader"><a node-type="close" href="#"><img src="<%=basePath%>images/Popupclose01.png" width="28" height="28"></a></div>';
		HTML += '<div class="Popup_A"><div class="Popup_A_1">';
				HTML += '<div class="Popup_title"><h2>增加栏目</h2></div>';
				HTML += '<iframe width="100%" height="400" src="'+ url +'" scrolling="no" frameborder="0"></iframe>';
				HTML += '</div></div>'
				HTML += '<div class="Popupfoot"><img src="<%=basePath%>images/Popupbg01_footer.png" width="550" height="15"></div></div>';
		$.dialog({skin:false,content:HTML});
	};

	/**
	 *把指定的一组checkbox所选的值构造为逗号分隔的字符串
	 */
	function getAllValue(group_box) {
		var boxes = document.getElementsByName(group_box);
		var values = "";
		for (var i = 0; i < boxes.length; i++) {
			if (boxes[i].checked) {
				values += boxes[i].value + ",";
			}
		}
		if (values.length > 0) {
			values = values.substring(0, values.length - 1);
		}
		return values;
	};
	// 删除
	function toDelete(){
		var operatorIds = getAllValue("group_box");
		if(!operatorIds){
			alert("请选择需要删除的栏目！");
			return;
		}

		if(confirm("确认删除？")){
			$.ajax({
			  url: "<%=basePath%>column/toDelete",
			  type:"POST",
			  contentType:"application/x-www-form-urlencoded; charset=utf-8",
			  data: "strColumns="+operatorIds,
			  dataType: 'text',
			  success: function(data) {
				 var jsonobj=eval('('+data+')');
				 if(jsonobj.state==='1'){
					refreshColumns();
					alert(jsonobj.result);
				 } else if(jsonobj.state==='0'){
					 alert(jsonobj.result);
				 }
			  },
			  error: function(XMLHttpRequest, textStatus, errorThrown) {
					 alert("删除失败！");
			  }
			});
		}
	};
	// 更新
	function toUpdate(columnID){

		var url = "<%=basePath%>column/update?intColumnID="+columnID;
		var HTML = '<div class="Popup">';
		HTML += '<div class="Popupheader"><a node-type="close" href="#"><img src="<%=basePath%>images/Popupclose01.png" width="28" height="28"></a></div>';
		HTML += '<div class="Popup_A"><div class="Popup_A_1">';
				HTML += '<div class="Popup_title"><h2>修改栏目</h2></div>';
				HTML += '<iframe width="100%" height="400" src="'+ url +'" scrolling="no" frameborder="0"></iframe>';
				HTML += '</div></div>'
				HTML += '<div class="Popupfoot"><img src="<%=basePath%>images/Popupbg01_footer.png" width="550" height="15"></div></div>';
		$.dialog({skin:false,content:HTML});
	};

	//0: 上升  1：下降
	function changePosStat(cid,parentId,intFlag){

		  $.ajax({
				  url: "<%=basePath%>column/changePos",
				  type:"POST",
				  contentType:"application/x-www-form-urlencoded; charset=utf-8",
				  data: {"cid":cid,"intFlag":intFlag,"parentId":parentId},
				  dataType: 'text',
				  success: function(data) {
					 var jsonobj=eval('('+data+')');
					 if(jsonobj.state==='1'){
						refreshColumns();
						alert(jsonobj.result);
					 } else if(jsonobj.state==='0'){
						 alert(jsonobj.result);
					 }
				  },
				  error: function(XMLHttpRequest, textStatus, errorThrown) {
						 alert("修改失败！");
				  }
			}); 
	};
	
	// 局部刷新
	function refreshColumns(){
	    searchText = searchText?encodeURIComponent(searchText):"";
	    $.ajaxSetup ({ cache: false });
		$(".userContent").load("<%=basePath%>column/searchColumn?searchText="+searchText);
	};
	

</script>
<!--中间部分开始-->
<div class="main">
	<!-- 左侧 -->
<%-- 	<jsp:include page="/WEB-INF/views/account/sidebar.jsp" /> --%>
	<!-- /左侧 -->
	<!-- 核心内容区域 -->
<!-- 	<div id="iaas_layout_content" class="rightblock"> -->
	<div class="rightblock">
		<p class="shadow"></p>
		<div class="content">
			
			<div class="mainblock">
				<div class="tabA">
					<h1>
						<a href="<%=basePath%>column/operate" style="color:#585858">栏目管理</a>
					</h1>
				</div>
				<div class="lineone mt10">
<%-- 					<span> <img name="prevButton" src="<%=basePath%>images/back.png"
						class="prev linkhand" style="cursor:pointer;"
						onclick="prevPage();"> <img name="nextButton"
						src="<%=basePath%>images/next.png" class="next linkhand"
						style="cursor:pointer;" onclick="nextPage();" /> </span> --%>
					<div class="btn">
						<a href="javascript:void(0)" onclick="toInsert()"><img
							src="<%=basePath%>images/xz.gif" />新增</a><a href="javascript:void(0)"
							onclick="toDelete()"><img
							src="<%=basePath%>images/del.gif" />删除</a>
<!-- 							<a href="javascript:void(0)"
							onclick="viewRecycleBin()"><img
							src="../../../images/dustbin.gif" />查看回收站</a> -->
					</div>
					<div class="search">
						<input type="text" name="searchText" style="color:#666"
							placeholder="请输入栏目名称进行查询" onblur="blurSearch()" /> <img src="<%=basePath%>images/search.png"
							onclick="clickSearch()" style="cursor: pointer" />
					</div>
				</div>

				<table border="0" cellpadding="0" cellspacing="0"
					class="yhgltable mt10" style="width:93%">
					<tr>
						<td rowspan="2" class="userContent" valign="top">
						    <script type="text/javascript">
						    	// 禁止ie读取缓存
									$.ajaxSetup ({ 
									cache: false
									 });
			            		$(".userContent").load("<%=basePath%>column/showColumns");
			            	</script>
			            </td>
					</tr>
				</table>
				
			</div>
		</div>

	</div>
</div>
<!--中间部分结束-->
<!--底部开始-->
<jsp:include page="/WEB-INF/views/layouts/footer.jsp" />
<!--底部结束-->
</body>
</html>
